/*
@name: NativeUtils
@desc: 原生方法调用时的参数签名
@author: timoo
@date: 2022/11/26
*/
export class NativeUtils{
    public static getArgsSig(args:any[], returnType:any):string{
        let sig:string[] = ["("];
        for (let i = 0; i < args.length; i++) {
            const element = args[i];
            sig.push(this.getValueTypeStr(element))
        }
        sig.push(")", this.getValueTypeStr(returnType))
        return sig.join("");
    }

    public static getValueTypeStr(value:any):string{
        if(value == null || value == undefined){
            return "V";
        }
        let typeStr = typeof value;
        if(typeStr == "number"){
            if(value % 1 != 0){ //float
                return "F"
            }else{
                return "I"
            }
        }else if(typeStr == "boolean"){
            return "Z"
        }else if(typeStr == "string"){
            return "Ljava/lang/String;"
        }
    }
}
